package com.ymatou.iapi.trading.sellerquery2.testcase;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.trading.operate.parameter.BargainGroupService;
import com.ymatou.iapi.trading.operate.parameter.PlaceOrderResp;
import com.ymatou.iapi.trading.operate.parameter.PlaceOrderService;
import com.ymatou.iapi.trading.operate.parameter.req.BizVo;
import com.ymatou.iapi.trading.operate.testcase.Ts_ChangeOrderBizStatus;
import com.ymatou.iapi.trading.ordersync.service.SyncVerifyService;
import com.ymatou.iapi.trading.sellerquery2.parameter.sp.Sp_GetAppSellerOrders;
import com.ymatou.iapi.trading.sellerquery2.parameter.sp.Sp_GetAppSellerOrdersByOrderIds;
import com.ymatou.query.seller.trading.api.parameter.Common;
import com.ymatou.query.seller.trading.api.parameter.GetAppSellerOrdersBean;
import com.ymatou.query.seller.trading.api.parameter.GetAppSellerOrdersResponse;
import com.ymatou.query.seller.trading.api.parameter.GetSellerOrdersListV2Arguments;
import com.ymatou.query.seller.trading.api.service.OrderCreate;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.annotation.TestSuite;
import com.ymt.utils.tag.P1;
import com.ymt.utils.tag.P2;
import com.ymt.utils.tag.P3;
import com.ymttest.common.entitie.C2COrderInfo.C2COrderInfoExt;
import com.ymttest.common.entitie.SellerOrderInfoV3;
import com.ymttest.common.enums.DateTypeEnum;
import com.ymttest.common.enums.OrderFilterEnum;
import com.ymttest.common.enums.OrderStatusEnum;
import com.ymttest.database.model.ProductPromotion;
import com.ymttest.utils.DataUtil;
import com.ymttest.utils.DataUtil.KeyValuePair;
import com.ymttest.utils.EnvSetup;
import com.ymttest.utils.YMTDateUtil;
import com.ymttest.utils.constant.ECode;

/**
 * @author songyefeng
 * @desc 获取商家订单列表.开放: 多商品 and M端商品 and 主单号
 */
@TestSuite
public class Ts_GetAppSellerOrders {
	private static GetAppSellerOrdersBean request;
	// private static
	// com.ymatou.query.seller.trading.api.service.GetAppSellerOrdersCall call;
	private static com.ymatou.iapi.trading.sellerquery2.service.GetAppSellerOrdersCall call;

	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("获取商家订单列表.开放: 多商品 and M端商品 and 主单号");
	}

	@Before
	public void caseUp() {
		request = new GetAppSellerOrdersBean();
		// call = new
		// com.ymatou.query.seller.trading.api.service.GetAppSellerOrdersCall();
		call = new com.ymatou.iapi.trading.sellerquery2.service.GetAppSellerOrdersCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(call.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}

	private void verify() {
		GetAppSellerOrdersResponse expectedResponse = new GetAppSellerOrdersResponse();
		ConstructExpectedResponse(expectedResponse);
		GetAppSellerOrdersResponse actualResponse = call
				.getAppSellerOrdersResponse();
		DataUtil.verify(DataUtil.Integerr.GetValueOrDefault(expectedResponse
				.getLastOrderId()), DataUtil.Integerr
				.GetValueOrDefault(actualResponse.getLastOrderId()),
				"验证LastOrderId");
		List<SellerOrderInfoV3> expectOrders = expectedResponse.getOrders();
		List<SellerOrderInfoV3> actualOrders = actualResponse.getOrders();
		if (expectOrders == null) {
			DataUtil.verify(true, DataUtil.isNullOrEmpty(actualOrders),
					"验证Orders == null或者为空列表");
		} else {
			DataUtil.verify(expectOrders.size(), actualOrders.size(),
					"验证Orders.size()");
			if (expectOrders.size() == actualOrders.size()) {
				for (int i = 0; i < expectOrders.size(); i++) {
					DataUtil.verify(expectOrders.get(i).getOrderId(),
							actualOrders.get(i).getOrderId(), "验证orderId的排序");
					SellerOrderInfoV3 expect = expectOrders.get(i);
					int expOid = expect.getOrderId();
					boolean exists = actualOrders.stream().anyMatch(
							x -> x.getOrderId() == expOid);
					DataUtil.verify(true, exists,
							"验证期望的OrderId=[" + expect.getOrderId()
									+ "]在接口返回的Orders列表中是否存在");
					if (exists) {
						SellerOrderInfoV3 actual = actualOrders.stream()
								.filter(x -> x.getOrderId() == expOid)
								.collect(Collectors.toList()).get(0);
						verifyOrder(expect, actual);
					}
				}
			}
		}

	}

	/**
	 * 校验砍价团状态
	 * 
	 * */
	private static void verifyBizStaute() {

		List<SellerOrderInfoV3> orderList = call.getAppSellerOrdersResponse()
				.getOrders();

		if (orderList.size() > 0) {
			for (SellerOrderInfoV3 sellerOrderInfo : orderList) {

				BizVo biz = Ts_ChangeOrderBizStatus
						.getBizVosByOrderId(sellerOrderInfo.getOrderId());

				if (null == biz)
					continue;
				Logger.verifyEquals(3, biz.getBizStatus(),
						"验证砍价团状态为BizStatus=3");
			}

		}

	}

	private void verifyOrder(SellerOrderInfoV3 expect, SellerOrderInfoV3 actual) {
		DataUtil.verify(expect.getSalesType(), actual.getSalesType(),
				"验证OrderId=[" + expect.getOrderId() + "]的SalesType");
		DataUtil.verify(expect.getOrderGroupId(), actual.getOrderGroupId(),
				"验证OrderId=[" + expect.getOrderId() + "]的OrderGroupId");
		DataUtil.verify(expect.getOrderStatus(), actual.getOrderStatus(),
				"验证OrderId=[" + expect.getOrderId() + "]的OrderStatus");
		DataUtil.verify(expect.getRiskVerifiedStatus(),
				actual.getRiskVerifiedStatus(),
				"验证OrderId=[" + expect.getOrderId() + "]的RiskVerifiedStatus");
		DataUtil.verify(expect.getBuyerUserId(), actual.getBuyerUserId(),
				"验证OrderId=[" + expect.getOrderId() + "]的BuyerUserId");
		DataUtil.verify(expect.getBuyerUserLoginId(),
				actual.getBuyerUserLoginId(),
				"验证OrderId=[" + expect.getOrderId() + "]的BuyerUserLoginId");
		DataUtil.verify(expect.getLeaveWord(), actual.getLeaveWord(),
				"验证OrderId=[" + expect.getOrderId() + "]的LeaveWord");
		// DataUtil.verify(expect.isPaidInFull(), actual.isPaidInFull(),
		// "验证OrderId=[" + expect.getOrderId() + "]的PaidInFull");
		DataUtil.verify(expect.getSellerNote(), actual.getSellerNote(),
				"验证OrderId=[" + expect.getOrderId() + "]的SellerNote");
		// DataUtil.verify(expect.getBuyerInBlacklist(),
		// actual.getBuyerInBlacklist(),
		// "验证OrderId=[" + expect.getOrderId() + "]的BuyerInBlacklist");
		DataUtil.verify(expect.getNeedUploadIdCard(),
				actual.getNeedUploadIdCard(),
				"验证OrderId=[" + expect.getOrderId() + "]的NeedUploadIdCard");
		DataUtil.verify(expect.getHaveUploadedIdCard(),
				actual.getHaveUploadedIdCard(),
				"验证OrderId=[" + expect.getOrderId() + "]的HaveUploadedIdCard");
		DataUtil.verifyDateEquals(expect.getCreateOrderDate(),
				actual.getCreateOrderDate(),
				"验证OrderId=[" + expect.getOrderId() + "]的CreateOrderDate");
		DataUtil.verifyDateEquals(expect.getPaidTime(), actual.getPaidTime(),
				"验证OrderId=[" + expect.getOrderId() + "]的PaidTime");
		DataUtil.verifyDateEquals(expect.getPostpayTime(),
				actual.getPostpayTime(), "验证OrderId=[" + expect.getOrderId()
						+ "]的PostpayTime");
		DataUtil.verifyDateEquals(expect.getDeliveryTime(),
				actual.getDeliveryTime(), "验证OrderId=[" + expect.getOrderId()
						+ "]的DeliveryTime");
		DataUtil.verifyDateEquals(expect.getOrderCancelledTime(),
				actual.getOrderCancelledTime(),
				"验证OrderId=[" + expect.getOrderId() + "]的OrderCancelledTime");
		DataUtil.verifyDateEquals(expect.getOrderConfirmedTime(),
				actual.getOrderConfirmedTime(),
				"验证OrderId=[" + expect.getOrderId() + "]的OrderConfirmedTime");
		DataUtil.verifyDateEquals(expect.getApplyPostPayTime(),
				actual.getApplyPostPayTime(),
				"验证OrderId=[" + expect.getOrderId() + "]的ApplyPostPayTime");
		// DataUtil.verify(expect.getOnlyNeedPayOnce(),
		// actual.getOnlyNeedPayOnce(),
		// "验证OrderId=[" + expect.getOrderId() + "]的OnlyNeedPayOnce");
		DataUtil.verify(expect.getCouponCode(), actual.getCouponCode(),
				"验证OrderId=[" + expect.getOrderId() + "]的CouponCode");
		DataUtil.verify(expect.getSellerCouponCode(),
				actual.getSellerCouponCode(),
				"验证OrderId=[" + expect.getOrderId() + "]的SellerCouponCode");
		DataUtil.verifyDecimalEquals(expect.getTotalProductPrice(),
				actual.getTotalProductPrice(),
				"验证OrderId=[" + expect.getOrderId() + "]的TotalProductPrice");
		DataUtil.verifyDecimalEquals(expect.getFreight(), actual.getFreight(),
				"验证OrderId=[" + expect.getOrderId() + "]的Freight");
		DataUtil.verifyDecimalEquals(expect.getExpectedTotalPayAmount(),
				actual.getExpectedTotalPayAmount(),
				"验证OrderId=[" + expect.getOrderId()
						+ "]的ExpectedTotalPayAmount");
		DataUtil.verifyDecimalEquals(DataUtil.BigDecimall
				.GetValueOrDefault(expect.getCouponAmount()), actual
				.getCouponAmount(), "验证OrderId=[" + expect.getOrderId()
				+ "]的CouponAmount");
		DataUtil.verifyDecimalEquals(DataUtil.BigDecimall
				.GetValueOrDefault(expect.getSellerCouponAmount()), actual
				.getSellerCouponAmount(), "验证OrderId=[" + expect.getOrderId()
				+ "]的SellerCouponAmount");
		DataUtil.verifyDecimalEquals(expect.getSellerPromotionAmount(),
				actual.getSellerPromotionAmount(),
				"验证OrderId=[" + expect.getOrderId() + "]的SellerPromotionAmount");
		DataUtil.verifyDecimalEquals(expect.getGiftAmount(),
				actual.getGiftAmount(), "验证OrderId=[" + expect.getOrderId()
						+ "]的GiftAmount");
		DataUtil.verifyDecimalEquals(expect.getDiscount(),
				actual.getDiscount(), "验证OrderId=[" + expect.getOrderId()
						+ "]的Discount");
		DataUtil.verifyDecimalEquals(expect.getExpectedPayAmount(),
				actual.getExpectedPayAmount(),
				"验证OrderId=[" + expect.getOrderId() + "]的ExpectedPayAmount");
		DataUtil.verifyDecimalEquals(DataUtil.BigDecimall
				.GetValueOrDefault(expect.getExpectedPostpayAmount()), actual
				.getExpectedPostpayAmount(),
				"验证OrderId=[" + expect.getOrderId() + "]的ExpectedPostpayAmount");
		DataUtil.verifyDecimalEquals(DataUtil.BigDecimall
				.GetValueOrDefault(expect.getOriginalPostpayAmount()), actual
				.getOriginalPostpayAmount(),
				"验证OrderId=[" + expect.getOrderId() + "]的OriginalPostpayAmount");
		DataUtil.verify(DataUtil.Booleann.GetValueOrDefault(expect
				.getIsNewSellerOrder()), DataUtil.Booleann
				.GetValueOrDefault(actual.getIsNewSellerOrder()), "验证OrderId=["
				+ expect.getOrderId() + "]的IsNewSellerOrder");
		DataUtil.verify(DataUtil.Booleann.GetValueOrDefault(expect
				.getIsNewCustomerOrder()), DataUtil.Booleann
				.GetValueOrDefault(actual.getIsNewCustomerOrder()),
				"验证OrderId=[" + expect.getOrderId() + "]的IsNewCustomerOrder");
		List<com.ymatou.query.seller.trading.api.parameter.AppResponse.SellerOrderProductInfo> expProducts = expect
				.getProducts();
		List<com.ymatou.query.seller.trading.api.parameter.AppResponse.SellerOrderProductInfo> actProducts = actual
				.getProducts();
		if (DataUtil.isNullOrEmpty(expProducts)) {
			DataUtil.verify(null, actProducts,
					"验证OrderId=[" + expect.getOrderId() + "]的Products为空");
		} else {
			for (com.ymatou.query.seller.trading.api.parameter.AppResponse.SellerOrderProductInfo expProduct : expProducts) {
				String expProductId = expProduct.getProductId();
				boolean exists = actProducts.stream().anyMatch(
						x -> x.getProductId().equals(expProductId));
				DataUtil.verify(true, exists,
						"验证期望的OrderId=[" + expect.getOrderId()
								+ "]的ProductId=[" + expProductId + "]的产品记录是否存在");
				if (exists) {
					com.ymatou.query.seller.trading.api.parameter.AppResponse.SellerOrderProductInfo actProduct = actProducts
							.stream()
							.filter(x -> x.getProductId().equals(expProductId))
							.collect(Collectors.toList()).get(0);
					// verifyProduct(expProduct, actProduct,
					// expect.getOrderId(),
					// expProduct.getProductId());
					DataUtil.verify(
							true,
							actProducts.stream().anyMatch(
									x -> x.equals(expProduct)),
							"验证记录: \n" + expProduct + "\n是否存在于OrderId=["
									+ expect.getOrderId() + "]的Products列表中");

					Ts_GetAppSellerOrder.verifySubProducts(expect.getOrderId(),
							actProduct);
				}
			}
		}
	}

	private void verifyProduct(
			com.ymatou.query.seller.trading.api.parameter.AppResponse.SellerOrderProductInfo expect,
			com.ymatou.query.seller.trading.api.parameter.AppResponse.SellerOrderProductInfo actual,
			int oid, String pid) {
		DataUtil.verifyDecimalEquals(expect.getProductPrice(),
				actual.getProductPrice(), "验证期望的OrderId=[" + oid
						+ "]的ProductId=[" + pid + "]的ProductPrice");
		DataUtil.verifyDecimalEquals(expect.getProductOriginalPrice(),
				actual.getProductOriginalPrice(), "验证期望的OrderId=[" + oid
						+ "]的ProductId=[" + pid + "]的ProductOriginalPrice");
		DataUtil.verify(expect.getProductPictureUrl(),
				actual.getProductPictureUrl(), "验证期望的OrderId=[" + oid
						+ "]的ProductId=[" + pid + "]的ProductPictureUrl");
		DataUtil.verify(expect.getPropertyInfo(), actual.getPropertyInfo(),
				"验证期望的OrderId=[" + oid + "]的ProductId=[" + pid
						+ "]的PropertyInfo");
		DataUtil.verify(expect.getCatalogId(), actual.getCatalogId(),
				"验证期望的OrderId=[" + oid + "]的ProductId=[" + pid + "]的CatalogId");
		DataUtil.verify(expect.getProductNum(), actual.getProductNum(),
				"验证期望的OrderId=[" + oid + "]的ProductId=[" + pid + "]的ProductNum");
		DataUtil.verify(expect.getProductTitle(), actual.getProductTitle(),
				"验证期望的OrderId=[" + oid + "]的ProductId=[" + pid
						+ "]的ProductTitle");
		DataUtil.verify(expect.getPriceType(), actual.getPriceType(),
				"验证期望的OrderId=[" + oid + "]的ProductId=[" + pid + "]的PriceType");
		DataUtil.verify(expect.getLogisticsType(), actual.getLogisticsType(),
				"验证期望的OrderId=[" + oid + "]的ProductId=[" + pid
						+ "]的LogisticsType");
		DataUtil.verify(expect.getProductRefundChannel(),
				actual.getProductRefundChannel(), "验证期望的OrderId=[" + oid
						+ "]的ProductId=[" + pid + "]的ProductRefundChannel");
		DataUtil.verify(expect.isProductRefund(), actual.isProductRefund(),
				"验证期望的OrderId=[" + oid + "]的ProductId=[" + pid
						+ "]的ProductRefund");
		DataUtil.verify(
				DataUtil.Stringg.getValueOrDefault(expect.getSalesRefundCode()),
				DataUtil.Stringg.getValueOrDefault(actual.getSalesRefundCode()),
				"验证期望的OrderId=[" + oid + "]的ProductId=[" + pid
						+ "]的SalesRefundCode");
		DataUtil.verify(expect.getSalesRefundStatus(),
				actual.getSalesRefundStatus(), "验证期望的OrderId=[" + oid
						+ "]的ProductId=[" + pid + "]的SalesRefundStatus");
		DataUtil.verifyDecimalEquals(expect.getSalesRefundAmount(),
				actual.getSalesRefundAmount(), "验证期望的OrderId=[" + oid
						+ "]的ProductId=[" + pid + "]的SalesRefundAmount");
		DataUtil.verifyDecimalEquals(expect.getCouponAmount(),
				actual.getCouponAmount(), "验证期望的OrderId=[" + oid
						+ "]的ProductId=[" + pid + "]的CouponAmount");
		DataUtil.verifyDecimalEquals(expect.getSellerCouponAmount(),
				actual.getSellerCouponAmount(), "验证期望的OrderId=[" + oid
						+ "]的ProductId=[" + pid + "]的SellerCouponAmount");
		DataUtil.verifyDecimalEquals(expect.getFreightPartialAmount(),
				actual.getFreightPartialAmount(), "验证期望的OrderId=[" + oid
						+ "]的ProductId=[" + pid + "]的FreightPartialAmount");
		DataUtil.verifyDecimalEquals(expect.getDiscountPartialAmount(),
				actual.getDiscountPartialAmount(), "验证期望的OrderId=[" + oid
						+ "]的ProductId=[" + pid + "]的DiscountPartialAmount");
		DataUtil.verify(expect.getTariffType(), actual.getTariffType(),
				"验证期望的OrderId=[" + oid + "]的ProductId=[" + pid + "]的TariffType");
		DataUtil.verify(expect.getFreightFree(), actual.getFreightFree(),
				"验证期望的OrderId=[" + oid + "]的ProductId=[" + pid
						+ "]的FreightFree");
		DataUtil.verify(expect.getSupportRtnWithoutReason(),
				actual.getSupportRtnWithoutReason(), "验证期望的OrderId=[" + oid
						+ "]的ProductId=[" + pid + "]的SupportRtnWithoutReason");
		// DataUtil.verify(expect.getCatalogStatus(),
		// actual.getCatalogStatus(), "验证期望的OrderId=[" + oid
		// + "]的ProductId=[" + pid + "]的CatalogStatus");
		DataUtil.verify(expect.getCatalogType(), actual.getCatalogType(),
				"验证期望的OrderId=[" + oid + "]的ProductId=[" + pid
						+ "]的CatalogType");
		ProductPromotion expPromotion = expect.getPromotion();
		ProductPromotion actPromotion = actual.getPromotion();
		if (expPromotion == null) {
			DataUtil.verify(null, actPromotion, "验证期望的OrderId=[" + oid
					+ "]的ProductId=[" + pid + "]的Promotion为null");
		} else {
			verifyPromotion(expPromotion, actPromotion, oid, pid);
		}
	}

	private void verifyPromotion(ProductPromotion expected,
			ProductPromotion actual, int oid, String pid) {
		DataUtil.verify(expected.getCondition(), actual.getCondition(),
				"验证期望的OrderId=[" + oid + "]的ProductId=[" + pid
						+ "]的Promotion的Condition");
		DataUtil.verify(expected.getContent(), actual.getContent(),
				"验证期望的OrderId=[" + oid + "]的ProductId=[" + pid
						+ "]的Promotion的Content");
		DataUtil.verify(expected.getID(), actual.getID(), "验证期望的OrderId=["
				+ oid + "]的ProductId=[" + pid + "]的Promotion的ID");
		DataUtil.verify(expected.getName(), actual.getName(), "验证期望的OrderId=["
				+ oid + "]的ProductId=[" + pid + "]的Promotion的Name");
		DataUtil.verify(expected.getType(), actual.getType(), "验证期望的OrderId=["
				+ oid + "]的ProductId=[" + pid + "]的Promotion的Type");
		DataUtil.verifyDecimalEquals(expected.getPartialReducedAmount(),
				actual.getPartialReducedAmount(), "验证期望的OrderId=[" + oid
						+ "]的ProductId=[" + pid
						+ "]的Promotion的PartialReducedAmount");
		DataUtil.verifyDecimalEquals(expected.getReducedAmount(),
				actual.getReducedAmount(), "验证期望的OrderId=[" + oid
						+ "]的ProductId=[" + pid + "]的Promotion的ReducedAmount");
	}

	private void ConstructExpectedResponse(GetAppSellerOrdersResponse response) {
		GetSellerOrdersListV2Arguments args = new GetSellerOrdersListV2Arguments();
		SetArguments(args);
		Sp_GetAppSellerOrdersByOrderIds sp = Execute(args);
		List<SellerOrderInfoV3> orders = com.ymatou.query.seller.trading.api.parameter.SellerApp.Common
				.GetAppSellerOrdersFromDB(sp, false);
		response.setOrders(orders);
		if (DataUtil.isNullOrEmpty(orders) == false) {
			int lastId = orders.stream().map(x -> x.getOrderId())
					.min((x, y) -> x - y).get();
			response.setLastOrderId(lastId);
		}
	}

	private Sp_GetAppSellerOrdersByOrderIds Execute(
			GetSellerOrdersListV2Arguments args) {
		Sp_GetAppSellerOrders sp = new Sp_GetAppSellerOrders();
		sp.setSellerId(args.getSellerId());
		sp.setOrderSellerAcceptedStatus(args.getOrderSellerAcceptedStatus());
		sp.setOrderStatus(args.getOrderStatus());
		sp.setLastOrderId(args.getLastOrderId());
		sp.setTimeFrom(DataUtil.Stringg.isNullOrEmpty(args.getTimeFrom())
				? args.getTimeFrom()
				: args.getTimeFrom().substring(0, 10));
		sp.setTimeTo(args.getTimeTo());
		sp.setTop(args.getTopCount());
		sp.setFilter(args.getFilter() == null ? 0 : args.getFilter().getKey());
		sp.setFilterValue(args.getFilter() == null ? null : args.getFilter()
				.getValue());
		sp.setPaidInFull(args.getPaidInFull());
		return sp.execute();
	}

	private GetSellerOrdersListV2Arguments SetArguments(
			GetSellerOrdersListV2Arguments args) {
		args.setSellerId(request.getSellerUserId());
		args.setLastOrderId(DataUtil.Integerr.GetValueOrDefault(request
				.getLastOrderId()));
		args.setTopCount(DataUtil.Integerr.GetValueOrDefault(
				request.getOrderNum(), 100000));
		// args.setOrderSellerAcceptedStatus(OrderStatusEnum.SellerAccept
		// .getValue());
		if (request.getFilter() != null) {
			args.setFilter(request.getFilter());
		}
		// SetPaidInFullAndStatus(args);
		SetOrderStatus(args);
		SetTimeRange(args);
		return args;
	}

	private void SetOrderStatus(GetSellerOrdersListV2Arguments args) {
		if (DataUtil.isNullOrEmpty(request.getOrderStatusList())) {
			List<Integer> defaultStatus = new ArrayList<Integer>();
			defaultStatus.add(OrderStatusEnum.OrderEstablish.getValue());
			defaultStatus.add(OrderStatusEnum.AccountPaid.getValue());
			defaultStatus.add(OrderStatusEnum.Shipped.getValue());
			defaultStatus.add(OrderStatusEnum.Received.getValue());
			defaultStatus.add(OrderStatusEnum.SellerAccept.getValue());
			args.setOrderStatus(defaultStatus);
		} else {
			args.setOrderStatus(request.getOrderStatusList());
		}
	}

	@Deprecated
	private void SetPaidInFullAndStatus(GetSellerOrdersListV2Arguments args) {
		Boolean paidInFull = null;
		if (request.getOrderStatusList() == null) {
			request.setOrderStatusList(new ArrayList<Integer>());
		}
		args.setOrderStatus(Common.GetSellerOrderStatus(
				request.getOrderStatusList(), true));
		paidInFull = Common.paidInFull;
		args.setPaidInFull(paidInFull);
		SetTimeRange(args);
	}

	private void SetTimeRange(GetSellerOrdersListV2Arguments args) {
		if (DataUtil.isNullOrEmpty(request.getDateList())
				&& request.getBeginTime() == null
				&& request.getEndTime() == null) {
			return;
		}
		String format = YMTDateUtil.YMD;
		//2017-1-20新增逻辑- 传begintime或者endtime后，会忽略datalist
		if (request.getBeginTime() != null || request.getEndTime() != null) {
			args.setTimeFrom(YMTDateUtil.getBeforeOrNextDay(
					request.getBeginTime(), 0, format));
			args.setTimeTo(YMTDateUtil.getBeforeOrNextDay(request.getEndTime(),
					0, format));
		} else {
			List<Integer> temp = new ArrayList<Integer>();
			temp.addAll(request.getDateList());
			//2017-1-20新增逻辑 - datalist中包含0, 则查找距今(包含今天)往前6个月内的订单
			if (temp.contains(DateTypeEnum.All.getValue())) {
				args.setTimeFrom(YMTDateUtil.getBeforeOrNextMonth(-6, format));
				args.setTimeTo(YMTDateUtil.getBeforeOrNextDay(1, format));
				return;
			}
			if (temp.removeIf(x -> x == DateTypeEnum.All.getValue())
					&& temp.size() == 0) {
				return;
			}
			String today = YMTDateUtil.getBeforeOrNextDay(0, format);
			boolean yesterday = false;
			if (temp.removeIf(x -> x == DateTypeEnum.Yesterday.getValue())) {
				yesterday = true;
				if (temp.size() == 0) {
					args.setTimeFrom(YMTDateUtil.getBeforeOrNextDay(-1, format));
					args.setTimeTo(today);
					return;
				}
			}
			int minvalue = temp.stream().max((a, b) -> a - b).get();
			com.ymatou.query.seller.trading.api.parameter.TimeRange min = Common
					.ToTimeRange(minvalue);
			if (min == null) {
				args.setTimeFrom(today);
				args.setTimeTo(YMTDateUtil.getBeforeOrNextDay(-1, format)
						+ "T00:00:00");
				return;
			}
			args.setTimeFrom(min.getBegin());
			args.setTimeTo(min.getEnd());
			if (!yesterday) {
				return;
			}
			if (YMTDateUtil.parseDate(args.getTimeFrom(), format)
					.compareTo(
							YMTDateUtil.parseDate(
									YMTDateUtil.getBeforeOrNextDay(-1, format),
									format)) <= 0) {
				args.setTimeFrom(YMTDateUtil.getBeforeOrNextDay(-1, format)
						+ "T00:00:00");
				args.setTimeTo(today);
			} else {
				args.setTimeFrom(today);
				args.setTimeTo(YMTDateUtil.getBeforeOrNextDay(-1, format)
						+ "T00:00:00");
			}
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetAppSellerOrders_001() {
		Logger.start(true, "获取商家订单列表成功, 参数全传");
		int sellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
		int userId = Integer.valueOf(EnvSetup.getData("BuyUserId"));
		String orderId = String.valueOf(new OrderCreate().create1_M2cOrder(
				userId, sellerId).getiOrderId());
		try {
			Integer LastOrderId = 0;
			int OrderNum = 10;

			List<Integer> DateList = new ArrayList<Integer>();
			DateList.add(DateTypeEnum.ThisQuarter.getValue());

			List<Integer> OrderStatusList = new ArrayList<Integer>();
			OrderStatusList.add(OrderStatusEnum.AccountPaid.getValue());

			KeyValuePair<Integer, String> Filter = new KeyValuePair<Integer, String>();
			Filter.setKey(OrderFilterEnum.OrderId.getValue());
			Filter.setValue(orderId);

			request.setSellerUserId(sellerId);
			request.setOrderNum(OrderNum);
			request.setLastOrderId(LastOrderId);
			request.setDateList(DateList);
			request.setOrderStatusList(OrderStatusList);
			request.setFilter(Filter);
			// seller 后台发送请求
			call.setData(request);
			call.callService();
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}

	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetAppSellerOrders_002() {
		Logger.start(true, "获取商家订单列表成功,只有Filter为null");
		try {
			int sellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			List<Integer> DateList = new ArrayList<Integer>();
			DateList.add(DateTypeEnum.ThisMonth.getValue());
			List<Integer> OrderStatusList = new ArrayList<Integer>();
			OrderStatusList.add(OrderStatusEnum.Received.getValue());
			request.setSellerUserId(sellerId);
			request.setOrderNum(10);
			request.setOrderStatusList(OrderStatusList);
			call.setData(request);
			call.callService();

			DataUtil.verify("200", call.getCode(), "验证errorcode");

			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetAppSellerOrders_003() {
		Logger.start(true, "获取商家订单列表成功, 验证OrderStatusEnum参数枚举值--订单确立/（未付款）");
		try {
			int SellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			List<Integer> OrderStatusList = new ArrayList<Integer>();
			OrderStatusList.add(OrderStatusEnum.OrderEstablish.getValue());
			request.setSellerUserId(SellerId);
			request.setOrderNum(10);
			request.setOrderStatusList(OrderStatusList);
			call.setData(request);
			call.callService();
			DataUtil.verify("200", call.getCode(), "验证errorcode");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetAppSellerOrders_004() {
		Logger.start(true, "获取商家订单列表成功, 验证OrderStatusEnum参数枚举值--已付款");
		try {
			int SellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			List<Integer> OrderStatusList = new ArrayList<Integer>();
			OrderStatusList.add(OrderStatusEnum.AccountPaid.getValue());
			request.setSellerUserId(SellerId);
			request.setOrderNum(10);
			request.setOrderStatusList(OrderStatusList);
			call.setData(request);
			call.callService();
			DataUtil.verify("200", call.getCode(), "验证errorcode");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetAppSellerOrders_005() {
		Logger.start(true, "获取商家订单列表成功, 验证OrderStatusEnum参数枚举值--已发货");
		try {
			int SellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			List<Integer> OrderStatusList = new ArrayList<Integer>();
			OrderStatusList.add(OrderStatusEnum.Shipped.getValue());
			request.setSellerUserId(SellerId);
			request.setOrderNum(10);
			request.setOrderStatusList(OrderStatusList);
			call.setData(request);
			call.callService();
			DataUtil.verify("200", call.getCode(), "验证errorcode");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetAppSellerOrders_006() {
		Logger.start(true, "获取商家订单列表成功, 验证OrderStatusEnum参数枚举值--确认收货");
		try {
			int SellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			List<Integer> OrderStatusList = new ArrayList<Integer>();
			OrderStatusList.add(OrderStatusEnum.Received.getValue());
			request.setSellerUserId(SellerId);
			request.setOrderNum(10);
			request.setOrderStatusList(OrderStatusList);
			call.setData(request);
			call.callService();
			DataUtil.verify("200", call.getCode(), "验证errorcode");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetAppSellerOrders_007() {
		Logger.start(true, "获取商家订单列表成功, 验证OrderStatusEnum参数枚举值--买家取消订单");
		try {
			int SellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			List<Integer> OrderStatusList = new ArrayList<Integer>();
			OrderStatusList.add(OrderStatusEnum.UserAcceptCancel.getValue());
			request.setSellerUserId(SellerId);
			request.setOrderNum(10);
			request.setOrderStatusList(OrderStatusList);
			call.setData(request);
			call.callService();
			DataUtil.verify("200", call.getCode(), "验证errorcode");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetAppSellerOrders_008() {
		Logger.start(true, "获取商家订单列表成功, 验证OrderStatusEnum参数枚举值--卖家取消订单");
		try {
			int SellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			List<Integer> OrderStatusList = new ArrayList<Integer>();
			OrderStatusList.add(OrderStatusEnum.SellerAcceptCancel.getValue());
			request.setSellerUserId(SellerId);
			request.setOrderNum(10);
			request.setOrderStatusList(OrderStatusList);
			call.setData(request);
			call.callService();
			DataUtil.verify("200", call.getCode(), "验证errorcode");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetAppSellerOrders_009() {
		Logger.start(true, "获取商家订单列表成功, 验证OrderStatusEnum参数枚举值--系统自动取消");
		try {
			int SellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			List<Integer> OrderStatusList = new ArrayList<Integer>();
			OrderStatusList.add(OrderStatusEnum.SystemCancel.getValue());
			request.setSellerUserId(SellerId);
			request.setOrderNum(10);
			request.setOrderStatusList(OrderStatusList);
			call.setData(request);
			call.callService();
			DataUtil.verify("200", call.getCode(), "验证errorcode");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetAppSellerOrders_011() {
		Logger.start(true, "获取商家订单列表成功, 验证OrderStatusEnum参数枚举值--订单补款完成(等待发货)");
		try {
			int SellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			List<Integer> OrderStatusList = new ArrayList<Integer>();
			OrderStatusList.add(OrderStatusEnum.SellerAccept.getValue());
			request.setSellerUserId(SellerId);
			request.setOrderNum(10);
			request.setOrderStatusList(OrderStatusList);
			call.setData(request);
			call.callService();
			DataUtil.verify("200", call.getCode(), "验证errorcode");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetAppSellerOrders_012() {
		Logger.start(true, "获取商家订单列表成功, 验证OrderStatusEnum参数枚举值--自动取消订单");
		try {
			int SellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			List<Integer> OrderStatusList = new ArrayList<Integer>();
			OrderStatusList.add(OrderStatusEnum.AutoCancel.getValue());
			OrderStatusList.add(300);
			request.setSellerUserId(SellerId);
			request.setOrderNum(10);
			request.setOrderStatusList(OrderStatusList);
			call.setData(request);
			call.callService();
			DataUtil.verify("200", call.getCode(), "验证errorcode");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_GetAppSellerOrders_019() {
		Logger.start(true, "获取商家订单列表成功, 全部状态的订单");
		try {
			int SellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			List<Integer> OrderStatusList = new ArrayList<Integer>();
			OrderStatusList.add(OrderStatusEnum.OrderEstablish.getValue());
			OrderStatusList.add(OrderStatusEnum.AccountPaid.getValue());
			OrderStatusList.add(OrderStatusEnum.SellerAccept.getValue());
			OrderStatusList.add(OrderStatusEnum.Shipped.getValue());
			OrderStatusList.add(OrderStatusEnum.Received.getValue());
			OrderStatusList.add(OrderStatusEnum.SystemCancel.getValue());
			OrderStatusList.add(OrderStatusEnum.UserAcceptCancel.getValue());
			OrderStatusList.add(OrderStatusEnum.SellerAcceptCancel.getValue());
			request.setSellerUserId(SellerId);
			request.setOrderNum(10);
			request.setOrderStatusList(OrderStatusList);
			call.setData(request);
			call.callService();
			DataUtil.verify("200", call.getCode(), "验证errorcode");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_GetAppSellerOrders_021() {
		Logger.start(true, "获取商家订单列表为空,不存在的订单状态");
		try {
			int SellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			List<Integer> OrderStatusList = new ArrayList<Integer>();
			OrderStatusList.add(123132);
			request.setSellerUserId(SellerId);
			request.setOrderNum(10);
			request.setOrderStatusList(OrderStatusList);
			call.setData(request);
			call.callService();
			DataUtil.verify("200", call.getCode(), "验证errorcode");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_GetAppSellerOrders_022() {
		Logger.start(true, "获取商家订单列表失败,只传OrderNum");
		Integer OrderNum = 20;
		try {
			request.setOrderNum(OrderNum);
			call.setData(request);
			call.callService();
			Logger.verifyEquals(ECode.ERROR400, call.getCode(), "验证errorcode");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_GetAppSellerOrders_023() {
		Logger.start(true, "获取商家订单列表失败,只传Filter");
		try {
			KeyValuePair<Integer, String> Filter = new KeyValuePair<Integer, String>();
			Filter.setKey(OrderFilterEnum.OrderId.getValue());
			Filter.setValue("1");
			request.setFilter(Filter);
			call.setData(request);
			call.callService();
			Logger.verifyEquals(ECode.ERROR400, call.getCode(), "验证errorcode");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_GetAppSellerOrders_024() {
		Logger.start(true, "获取商家订单列表失败,只传LastOrderId");
		try {
			Integer LastOrderId = 129999999;
			request.setLastOrderId(LastOrderId);
			call.setData(request);
			call.callService();
			Logger.verifyEquals(ECode.ERROR400, call.getCode(), "验证errorcode");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_GetAppSellerOrders_025() {
		Logger.start(true, "获取商家订单列表失败,只传OrderStatusList");
		try {
			List<Integer> OrderStatusList = new ArrayList<Integer>();
			OrderStatusList.add(OrderStatusEnum.Received.getValue());

			request.setOrderStatusList(OrderStatusList);
			call.setData(request);
			call.callService();
			Logger.verifyEquals(ECode.ERROR400, call.getCode(), "验证errorcode");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P3.class)
	@TestCase
	@Ignore
	public void Tc_GetAppSellerOrders_027() {
		Logger.start(true,
				"获取商家订单列表成功,只传必填的SellerId和OrderStatusList(为了测试速度，并且防止产生oom，还是加上了OrderNum)");
		try {
			// Integer OrderNum = 10;
			// Integer LastOrderId = null;
			// List<Integer> DateList = null;
			int SellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			List<Integer> OrderStatusList = new ArrayList<Integer>();
			OrderStatusList.add(OrderStatusEnum.Received.getValue());
			request.setSellerUserId(SellerId);
			// request.setOrderNum(10);
			request.setOrderStatusList(OrderStatusList);
			call.setData(request);
			call.callService();
			DataUtil.verify("200", call.getCode(), "验证errorcode");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetAppSellerOrders_028() {
		Logger.start(true, "获取商家订单列表成功, DateList为空");
		try {
			List<Integer> OrderStatusList = new ArrayList<Integer>();
			OrderStatusList.add(OrderStatusEnum.Received.getValue());
			int SellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			request.setSellerUserId(SellerId);
			request.setOrderNum(10);
			request.setOrderStatusList(OrderStatusList);
			call.setData(request);
			call.callService();
			DataUtil.verify("200", call.getCode(), "验证errorcode");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}

	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetAppSellerOrders_029() {
		Logger.start(true, "获取商家订单列表成功, OrderStatusList为空");
		try {
			List<Integer> DateList = new ArrayList<Integer>();
			DateList.add(DateTypeEnum.ThisYear.getValue());
			int SellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			request.setSellerUserId(SellerId);
			request.setOrderNum(10);
			request.setDateList(DateList);
			call.setData(request);
			call.callService();
			DataUtil.verify("200", call.getCode(), "验证errorcode");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetAppSellerOrders_030() {
		Logger.start(true, "获取商家订单列表成功, 验证DataList参数枚举值--查询一年之内的订单");
		try {
			List<Integer> DateList = new ArrayList<Integer>();
			DateList.add(DateTypeEnum.ThisYear.getValue());
			int SellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			List<Integer> OrderStatusList = new ArrayList<Integer>();
			OrderStatusList.add(OrderStatusEnum.AccountPaid.getValue());
			request.setSellerUserId(SellerId);
			request.setOrderNum(10);
			request.setOrderStatusList(OrderStatusList);
			request.setDateList(DateList);
			call.setData(request);
			call.callService();
			DataUtil.verify("200", call.getCode(), "验证errorcode");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetAppSellerOrders_031() {
		Logger.start(true, "获取商家订单列表成功, 验证DataList参数枚举值--查询一个季度之内的订单");
		try {
			List<Integer> DateList = new ArrayList<Integer>();
			DateList.add(DateTypeEnum.ThisQuarter.getValue());
			int SellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			List<Integer> OrderStatusList = new ArrayList<Integer>();
			OrderStatusList.add(OrderStatusEnum.AccountPaid.getValue());
			request.setSellerUserId(SellerId);
			request.setOrderNum(20);
			request.setOrderStatusList(OrderStatusList);
			request.setDateList(DateList);
			call.setData(request);
			call.callService();
			DataUtil.verify("200", call.getCode(), "验证errorcode");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetAppSellerOrders_032() {
		Logger.start(true, "获取商家订单列表成功, 验证DataList参数枚举值--查询一个月之内的订单");
		try {
			List<Integer> DateList = new ArrayList<Integer>();
			DateList.add(DateTypeEnum.ThisMonth.getValue());
			int SellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			List<Integer> OrderStatusList = new ArrayList<Integer>();
			OrderStatusList.add(OrderStatusEnum.AccountPaid.getValue());
			request.setSellerUserId(SellerId);
			request.setOrderNum(12);
			request.setOrderStatusList(OrderStatusList);
			request.setDateList(DateList);
			call.setData(request);
			call.callService();
			DataUtil.verify("200", call.getCode(), "验证errorcode");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}

	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetAppSellerOrders_033() {
		Logger.start(true, "获取商家订单列表成功, 验证DataList参数枚举值--查询一个星期之内的订单");
		try {
			List<Integer> DateList = new ArrayList<Integer>();
			DateList.add(DateTypeEnum.ThisWeek.getValue());
			int SellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			List<Integer> OrderStatusList = new ArrayList<Integer>();
			OrderStatusList.add(OrderStatusEnum.AccountPaid.getValue());
			request.setSellerUserId(SellerId);
			request.setOrderNum(12);
			request.setOrderStatusList(OrderStatusList);
			request.setDateList(DateList);
			call.setData(request);
			call.callService();
			DataUtil.verify("200", call.getCode(), "验证errorcode");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetAppSellerOrders_034() {
		Logger.start(true, "获取商家订单列表成功, 验证DataList参数枚举值--查询今天的订单");
		try {
			List<Integer> DateList = new ArrayList<Integer>();
			DateList.add(DateTypeEnum.Today.getValue());
			int SellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			List<Integer> OrderStatusList = new ArrayList<Integer>();
			OrderStatusList.add(OrderStatusEnum.AccountPaid.getValue());
			request.setSellerUserId(SellerId);
			request.setOrderNum(12);
			request.setOrderStatusList(OrderStatusList);
			request.setDateList(DateList);
			call.setData(request);
			call.callService();
			DataUtil.verify("200", call.getCode(), "验证errorcode");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetAppSellerOrders_035() {
		Logger.start(true, "获取商家订单列表成功, 验证DataList参数枚举值--查询昨天的订单");
		try {
			List<Integer> DateList = new ArrayList<Integer>();
			DateList.add(DateTypeEnum.Yesterday.getValue());
			int SellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			List<Integer> OrderStatusList = new ArrayList<Integer>();
			OrderStatusList.add(OrderStatusEnum.AccountPaid.getValue());
			request.setSellerUserId(SellerId);
			request.setOrderNum(12);
			request.setOrderStatusList(OrderStatusList);
			request.setDateList(DateList);
			call.setData(request);
			call.callService();
			DataUtil.verify("200", call.getCode(), "验证errorcode");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetAppSellerOrders_036() {
		Logger.start(true, "获取商家订单列表成功,验证DataList参数枚举值--查询所有天的订单");
		try {
			List<Integer> DateList = new ArrayList<Integer>();
			DateList.add(DateTypeEnum.ThisMonth.getValue());
			int SellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			List<Integer> OrderStatusList = new ArrayList<Integer>();
			OrderStatusList.add(OrderStatusEnum.AccountPaid.getValue());
			request.setSellerUserId(SellerId);
			request.setOrderNum(6);
			request.setOrderStatusList(OrderStatusList);
			request.setDateList(DateList);
			call.setData(request);
			call.callService();
			DataUtil.verify("200", call.getCode(), "验证errorcode");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetAppSellerOrders_037() {
		Logger.start(true, "获取商家订单列表成功, 验证Filter参数--1：iOrderId");
		try {
			List<Integer> DateList = new ArrayList<Integer>();
			DateList.add(DateTypeEnum.All.getValue());
			int SellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			// List<Integer> OrderStatusList = new ArrayList<Integer>();

			KeyValuePair<Integer, String> Filter = new KeyValuePair<Integer, String>();
			Filter.setKey(OrderFilterEnum.OrderId.getValue());
			Filter.setValue("12");
			request.setSellerUserId(SellerId);
			request.setFilter(Filter);
			request.setDateList(DateList);
			request.setOrderNum(10);
			call.setData(request);
			call.callService();
			DataUtil.verify("200", call.getCode(), "验证errorcode");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}

	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetAppSellerOrders_038() {
		Logger.start(true, "获取商家订单列表成功, 验证Filter参数--3：sReceivePerson");
		try {
			List<Integer> DateList = new ArrayList<Integer>();
			DateList.add(DateTypeEnum.ThisYear.getValue());
			int SellerId = Integer.valueOf(EnvSetup.getData("SellerId"));

			KeyValuePair<Integer, String> Filter = new KeyValuePair<Integer, String>();
			Filter.setKey(OrderFilterEnum.ConsigneeName.getValue());
			Filter.setValue("李四");
			request.setSellerUserId(SellerId);
			request.setFilter(Filter);
			request.setDateList(DateList);
			request.setOrderNum(10);
			call.setData(request);
			call.callService();
			DataUtil.verify("200", call.getCode(), "验证errorcode");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}

	}

	@Test
	@Category(P1.class)
	@TestCase
	@Ignore
	public void Tc_GetAppSellerOrders_039() {
		Logger.start(true, "获取商家订单列表成功, 验证Filter参数--3：sReceivePerson, 空格");
		try {
			List<Integer> DateList = new ArrayList<Integer>();
			DateList.add(DateTypeEnum.ThisYear.getValue());
			int SellerId = Integer.valueOf(EnvSetup.getData("SellerId"));

			KeyValuePair<Integer, String> Filter = new KeyValuePair<Integer, String>();
			Filter.setKey(OrderFilterEnum.ConsigneeName.getValue());
			Filter.setValue(" ");
			request.setSellerUserId(SellerId);
			request.setFilter(Filter);
			request.setDateList(DateList);
			request.setOrderNum(10);
			call.setData(request);
			call.callService();
			DataUtil.verify("200", call.getCode(), "验证errorcode");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	@Ignore
	public void Tc_GetAppSellerOrders_040() {
		Logger.start(true, "获取商家订单列表成功, 验证Filter参数--2：sBuyerNickName, 空格");
		try {
			List<Integer> DateList = new ArrayList<Integer>();
			DateList.add(DateTypeEnum.ThisYear.getValue());
			int SellerId = Integer.valueOf(EnvSetup.getData("SellerId"));

			KeyValuePair<Integer, String> Filter = new KeyValuePair<Integer, String>();
			Filter.setKey(OrderFilterEnum.ConsumerNickname.getValue());
			Filter.setValue(" ");
			request.setSellerUserId(SellerId);
			request.setFilter(Filter);
			request.setDateList(DateList);
			request.setOrderNum(10);
			call.setData(request);
			call.callService();
			DataUtil.verify("200", call.getCode(), "验证errorcode");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}

	}

	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_GetAppSellerOrders_041() {
		Logger.start(true, "获取商家订单列表失败,只传SellerUserId,OrderNum,LastOrderId");
		try {
			int SellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			request.setLastOrderId(12000000);
			request.setSellerUserId(SellerId);
			request.setOrderNum(10);
			call.setData(request);
			call.callService();
			DataUtil.verify(200, call.getCode(), "验证Code");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetAppSellerOrders_042() {
		Logger.start(true, "获取商家订单列表成功, 若filter的key=4, 走es查询 ");
		try {
			List<Integer> DateList = new ArrayList<Integer>();
			DateList.add(DateTypeEnum.ThisYear.getValue());
			int SellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			List<Integer> OrderStatusList = new ArrayList<Integer>();

			KeyValuePair<Integer, String> Filter = new KeyValuePair<Integer, String>();
			Filter.setKey(OrderFilterEnum.TrackingNO.getValue());
			Filter.setValue("DB683214922Us");
			request.setSellerUserId(SellerId);
			request.setOrderStatusList(OrderStatusList);
			request.setFilter(Filter);
			request.setDateList(DateList);
			request.setLastOrderId(0);
			request.setOrderNum(10);
			call.setData(request);
			call.callService();
			DataUtil.verify("200", call.getCode(), "验证errorcode");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetAppSellerOrders_043() {
		Logger.start(true, "获取商家订单列表成功, 测试LastOrderId ");
		try {
			Logger.comment("准备前置数据");
			OrderCreate c = new OrderCreate();
			int SellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			int userId = Integer.valueOf(EnvSetup.getData("BuyUserId"));
			c.create2_PayOrder(userId, SellerId);
			C2COrderInfoExt order = c.create2_PayOrder(userId, SellerId);
			int lastOrderId = order.getiOrderId();
			c.create2_PayOrder(userId, SellerId);
			c.create2_PayOrder(userId, SellerId);
			Logger.comment("前置数据准备结束");
			List<Integer> DateList = new ArrayList<Integer>();
			DateList.add(DateTypeEnum.All.getValue());
			List<Integer> OrderStatusList = new ArrayList<Integer>();
			OrderStatusList.add(OrderStatusEnum.AccountPaid.getValue());

			request.setSellerUserId(SellerId);
			request.setLastOrderId(lastOrderId);
			request.setOrderStatusList(OrderStatusList);
			request.setDateList(DateList);
			request.setOrderNum(10);
			call.setData(request);
			call.callService();
			DataUtil.verify("200", call.getCode(), "验证errorcode");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}

	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetAppSellerOrders_044() {
		Logger.start(true,
				"获取商家订单列表为空, 2017-1-20,修改逻辑,datetype=0时, 则查找距今(包含今天)往前6个月内的订单");
		try {
			int SellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			List<Integer> DateList = new ArrayList<Integer>();
			DateList.add(DateTypeEnum.ThisWeek.getValue());
			List<Integer> OrderStatusList = new ArrayList<Integer>();
			OrderStatusList.add(OrderStatusEnum.AccountPaid.getValue());

			request.setSellerUserId(SellerId);
			request.setOrderStatusList(OrderStatusList);
			request.setDateList(DateList);
			request.setOrderNum(10);
			call.setData(request);
			call.callService();
			DataUtil.verify("200", call.getCode(), "验证errorcode");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}

	}

	@Test
	@Category(P2.class)
	@TestCase
	public void Tc_GetAppSellerOrders_045() {
		Logger.start(true,
				"获取商家订单列表成功, 2017-1-20新增字段测试, 只传begintime(忽略DateList) ");
		try {
			List<Integer> DateList = new ArrayList<Integer>();
			DateList.add(DateTypeEnum.ThisYear.getValue());
			int SellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			List<Integer> OrderStatusList = new ArrayList<Integer>();

			request.setSellerUserId(SellerId);
			request.setOrderStatusList(OrderStatusList);
			request.setDateList(DateList);
			request.setLastOrderId(0);
			request.setOrderNum(10);
			request.setBeginTime(YMTDateUtil.getBeforeOrNextDay(-7,
					YMTDateUtil.YMD) + "T00:00:00");
			call.setData(request);
			call.callService();
			DataUtil.verify("200", call.getCode(), "验证errorcode");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P2.class)
	@TestCase
	public void Tc_GetAppSellerOrders_046() {
		Logger.start(true,
				"获取商家订单列表成功, 2017-1-20新增字段测试, 只传endTime(忽略DateList) ");
		try {
			List<Integer> DateList = new ArrayList<Integer>();
			DateList.add(DateTypeEnum.ThisYear.getValue());
			int SellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			List<Integer> OrderStatusList = new ArrayList<Integer>();

			request.setSellerUserId(SellerId);
			request.setOrderStatusList(OrderStatusList);
			request.setDateList(DateList);
			request.setLastOrderId(0);
			request.setOrderNum(10);
			request.setEndTime(YMTDateUtil.getBeforeOrNextDay(-3,
					YMTDateUtil.YMD) + "T00:00:00");
			call.setData(request);
			call.callService();
			DataUtil.verify("200", call.getCode(), "验证errorcode");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetAppSellerOrders_047() {
		Logger.start(true,
				"获取商家订单列表成功, 2017-1-20新增字段测试, 传beginTime+endTime(忽略DateList) ");
		try {
			List<Integer> DateList = new ArrayList<Integer>();
			DateList.add(DateTypeEnum.ThisYear.getValue());
			int SellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			List<Integer> OrderStatusList = new ArrayList<Integer>();

			request.setSellerUserId(SellerId);
			request.setOrderStatusList(OrderStatusList);
			request.setDateList(DateList);
			request.setLastOrderId(0);
			request.setOrderNum(10);
			request.setBeginTime(YMTDateUtil.getBeforeOrNextDay(-7,
					YMTDateUtil.YMD) + "T00:00:00");
			request.setEndTime(YMTDateUtil.getBeforeOrNextDay(1,
					YMTDateUtil.YMD) + "T00:00:00");
			call.setData(request);
			call.callService();
			DataUtil.verify("200", call.getCode(), "验证errorcode");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetAppSellerOrders_048() {
		Logger.start(true, "砍价团订单,组团成功,获取商家订单列表成功 ");
		try {
			Logger.comment("准备前置数据");

			PlaceOrderResp placeOrderResp = BargainGroupService.openGroup(null);

			int sellerId = placeOrderResp.getOrderList().get(0).getSellerId();
			// 砍价团id
			String bizId = placeOrderResp.getBizId();
			// 开团订单
			Integer orderId = placeOrderResp.getOrderList().get(0).getOrderId();

			// 砍价团参团订单
			PlaceOrderResp placeOrderResp2 = BargainGroupService
					.joinGroup(bizId);
			// 参团
			Integer orderId2 = placeOrderResp2.getOrderList().get(0)
					.getOrderId();

			BargainGroupService.notifyOrderBizStatus(bizId, orderId, 1, 3);

			Logger.comment("准备前置数据结束");

			SyncVerifyService.getSyncResult(orderId);

			List<Integer> OrderStatusList = new ArrayList<Integer>();
			OrderStatusList.add(OrderStatusEnum.AccountPaid.getValue());

			String beginTime = YMTDateUtil.getBeforeOrNextDay(-1,
					YMTDateUtil.YMDTHMS_STRING);

			String endTime = YMTDateUtil.getBeforeOrNextDay(1,
					YMTDateUtil.YMDTHMS_STRING);

			request.setSellerUserId(sellerId);

			request.setBeginTime(beginTime);
			request.setEndTime(endTime);

			request.setOrderNum(10);
			request.setOrderStatusList(OrderStatusList);
			request.setLastOrderId(orderId + 2);

			call.setData(request);
			call.callService();

			DataUtil.verify("200", call.getCode(), "验证errorcode");

			verify();

			verifyBizStaute();

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetAppSellerOrders_049() {
		Logger.start(true, "砍价团订单,组团失败,获取商家订单列表成功,砍价团订单未组团成功之前不展示 ");
		try {
			Logger.comment("准备前置数据");

			PlaceOrderResp placeOrderResp = BargainGroupService.openGroup(null);

			int sellerId = placeOrderResp.getOrderList().get(0).getSellerId();
			// 砍价团id
			String bizId = placeOrderResp.getBizId();
			// 开团订单
			Integer orderId = placeOrderResp.getOrderList().get(0).getOrderId();

			// 砍价团参团订单
			PlaceOrderResp placeOrderResp2 = BargainGroupService
					.joinGroup(bizId);
			// 参团
			Integer orderId2 = placeOrderResp2.getOrderList().get(0)
					.getOrderId();

			BargainGroupService.notifyOrderBizStatus(bizId, orderId, 1, -3);

			Logger.comment("准备前置数据结束");

			SyncVerifyService.getSyncResult(orderId);

			List<Integer> OrderStatusList = new ArrayList<Integer>();
			OrderStatusList.add(OrderStatusEnum.AccountPaid.getValue());

			String beginTime = YMTDateUtil.getBeforeOrNextDay(-1,
					YMTDateUtil.YMDTHMS_STRING);

			String endTime = YMTDateUtil.getBeforeOrNextDay(1,
					YMTDateUtil.YMDTHMS_STRING);

			request.setSellerUserId(sellerId);

			request.setBeginTime(beginTime);
			request.setEndTime(endTime);

			request.setOrderNum(10);
			request.setOrderStatusList(OrderStatusList);
			request.setLastOrderId(orderId + 2);

			call.setData(request);
			call.callService();

			DataUtil.verify("200", call.getCode(), "验证errorcode");

			verify();

			verifyBizStaute();

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetAppSellerOrders_050() {
		Logger.start(true, "砍价团订单,创建团,获取商家订单列表成功,砍价团订单未组团成功之前不展示 ");
		try {
			Logger.comment("准备前置数据");

			PlaceOrderResp placeOrderResp = BargainGroupService.openGroup(null);

			int sellerId = placeOrderResp.getOrderList().get(0).getSellerId();
			// 砍价团id
			String bizId = placeOrderResp.getBizId();
			// 开团订单
			Integer orderId = placeOrderResp.getOrderList().get(0).getOrderId();

			// 砍价团参团订单
			PlaceOrderResp placeOrderResp2 = BargainGroupService
					.joinGroup(bizId);
			// 参团
			Integer orderId2 = placeOrderResp2.getOrderList().get(0)
					.getOrderId();

			BargainGroupService.notifyOrderBizStatus(bizId, orderId, 1, 0);

			Logger.comment("准备前置数据结束");

			SyncVerifyService.getSyncResult(orderId);

			List<Integer> OrderStatusList = new ArrayList<Integer>();
			OrderStatusList.add(OrderStatusEnum.AccountPaid.getValue());

			String beginTime = YMTDateUtil.getBeforeOrNextDay(-1,
					YMTDateUtil.YMDTHMS_STRING);

			String endTime = YMTDateUtil.getBeforeOrNextDay(1,
					YMTDateUtil.YMDTHMS_STRING);

			request.setSellerUserId(sellerId);

			request.setBeginTime(beginTime);
			request.setEndTime(endTime);

			request.setOrderNum(10);
			request.setOrderStatusList(OrderStatusList);
			request.setLastOrderId(orderId + 2);

			call.setData(request);
			call.callService();

			DataUtil.verify("200", call.getCode(), "验证errorcode");

			verify();

			verifyBizStaute();

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetAppSellerOrders_051() {
		Logger.start(true, "获取商家订单列表成功, 参数全传");

		PlaceOrderResp placeOrderResp = PlaceOrderService.placeOrder10();

		int sellerId = placeOrderResp.getOrderList().get(0).getSellerId();

		Integer orderId = placeOrderResp.getOrderList().get(0).getOrderId();

		SyncVerifyService.getSyncResult(orderId);

		try {
			Integer LastOrderId = 0;
			int OrderNum = 10;

			List<Integer> DateList = new ArrayList<Integer>();
			DateList.add(DateTypeEnum.ThisWeek.getValue());

			List<Integer> OrderStatusList = new ArrayList<Integer>();
			OrderStatusList.add(OrderStatusEnum.OrderEstablish.getValue());

			KeyValuePair<Integer, String> Filter = new KeyValuePair<Integer, String>();

			Filter.setKey(OrderFilterEnum.OrderId.getValue());
			Filter.setValue(String.valueOf(orderId));

			request.setSellerUserId(sellerId);
			request.setOrderNum(OrderNum);
			request.setLastOrderId(LastOrderId);
			request.setDateList(DateList);
			request.setOrderStatusList(OrderStatusList);
			request.setFilter(Filter);
			// seller 后台发送请求
			call.setData(request);
			call.callService();

			verify();

		} catch (Exception e) {
			Logger.fail(e);
		}

	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetAppSellerOrders_052() {
		Logger.start(true, "新增按商品名称模糊查询,获取商家订单列表成功");

		PlaceOrderResp placeOrderResp = PlaceOrderService.placeOrder10();

		int sellerId = placeOrderResp.getOrderList().get(0).getSellerId();

		Integer orderId = placeOrderResp.getOrderList().get(0).getOrderId();

		SyncVerifyService.getSyncResult(orderId);
		try {
			Integer LastOrderId = 0;
			int OrderNum = 10;

			List<Integer> DateList = new ArrayList<Integer>();
			DateList.add(DateTypeEnum.ThisWeek.getValue());

			List<Integer> OrderStatusList = new ArrayList<Integer>();
			OrderStatusList.add(OrderStatusEnum.OrderEstablish.getValue());

			KeyValuePair<Integer, String> Filter = new KeyValuePair<Integer, String>();

			Filter.setKey(OrderFilterEnum.TITLE.getValue());
			Filter.setValue("测试商品");

			request.setSellerUserId(sellerId);
			request.setOrderNum(OrderNum);
			request.setLastOrderId(LastOrderId);
			request.setDateList(DateList);
			request.setOrderStatusList(OrderStatusList);
			request.setFilter(Filter);
			// seller 后台发送请求
			call.setData(request);
			call.callService();

			verify();

		} catch (Exception e) {
			Logger.fail(e);
		}

	}
}